// Copyright (C) 2012 Volkov Zachar
// This file is part of the "zAxis Game Engine".
// For conditions of distribution and use, see copyright notice zx_Common.hpp

#include "zx_Async.hpp"
#include <Windows.h>

namespace zx {

//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//
ThreadLocalStorage::ThreadLocalStorage( void ) : m_index( TlsAlloc() )
{
      SetPtr( 0 );
}
//----------------------------------------------------------------------------//
ThreadLocalStorage::ThreadLocalStorage( void* _ptr ) : m_index( TlsAlloc() )
{
      SetPtr( _ptr );
}
//----------------------------------------------------------------------------//
ThreadLocalStorage::~ThreadLocalStorage( void )
{
     TlsFree( m_index );
}
//----------------------------------------------------------------------------//
void* ThreadLocalStorage::GetPtr( void )
{
     return TlsGetValue( m_index );
}
//----------------------------------------------------------------------------//
void ThreadLocalStorage::SetPtr( void* _ptr )
{
     TlsSetValue( m_index, _ptr );
}
//----------------------------------------------------------------------------//
//----------------------------------------------------------------------------//

} // namespace zx
